# -*- coding: utf-8 -*-

#   This file is part of deckbuilder.
#
#    DeckBuilder is free software; you can redistribute it and/or modify
#    it under the terms of the GNU General Public License as published by
#    the Free Software Foundation; either version 2 of the License, or
#    (at your option) any later version.
#
#    DeckBuilder is distributed in the hope that it will be useful,
#    but WITHOUT ANY WARRANTY; without even the implied warranty of
#    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
#    GNU General Public License for more details.
#
#    You should have received a copy of the GNU General Public License
#    along with deckbuilder; if not, write to the Free Software
#    Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA

import os
import sys
import sqlite3

conn = sqlite3.connect(os.path.join(sys.path[0], 'cards.db'))
cursor = conn.cursor()
cursor.execute('CREATE TABLE cards (code TEXT, name TEXT, type TEXT, attribute TEXT, stars TEXT, type2 TEXT, atk TEXT, def TEXT, effect TEXT)')
path = os.path.join(sys.path[0], 'yvd.set')
file = open(path,)
for line in file:
    array = line.split('|')
    code = str(array[3]+'-'+array[2])
    name = str(array[1])
    type = str(array[4])
    attribute = str(array[5])
    stars = str(array[6])
    type2 = str(array[7])
    atk = str(array[8])
    df = str(array[9])
    effect = str(array[10])
    cursor.execute('INSERT INTO cards VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?)', (code, name, type, attribute, stars, type2, atk, df, effect))
conn.commit()